<?php
include_once('recaptchalib.php');

class HTGCaptcha {
	private static $PRIVATE_KEY='6Lez6scSAAAAAFGxTSjG2RAsCfpQoHNVMms5MzsX';
	private static $PUBLIC_KEY='6Lez6scSAAAAAKDf6gkd8Od996QoCu7csLkUqlKE';

	public $captchaForm=false;
	public $captchaError;
	public function __construct(){}

	public function getCaptchaForm() {
		if(!($this->captchaForm)) {
			$this->captchaForm = recaptcha_get_html(HTGCaptcha::$PUBLIC_KEY);
		}
		return $this->captchaForm;
	}	


	public function getCaptchaOptions() {
		return "<script type=\"text/javascript\">
	var RecaptchaOptions = {
		theme : 'blackglass'
	};
	</script>";
	}

	public function validateCaptcha() {
		$isValid=false;
		$resp = recaptcha_check_answer (HTGCaptcha::$PRIVATE_KEY,
		$_SERVER["REMOTE_ADDR"],
		$_REQUEST["recaptcha_challenge_field"],
		$_REQUEST["recaptcha_response_field"]);
		$isValid = $resp->is_valid;
		error_log("");	
		$this->captchaError = $resp->error;
		return $isValid;
	}
	
}